package com.techwells.heartfelt.viewobject;

import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;



/**
 * 视图类基类
 * 
 * @author 马蹄声
 * @version 1.0
 *
 */
public class BaseViewObject<V extends BaseViewObject<V>> 
        implements Serializable {

    private static final long serialVersionUID = 8950660914544659827L;

    protected Class<V> viewObjectClass;

    @SuppressWarnings("unchecked")
    public BaseViewObject() {
        Type type = getClass().getGenericSuperclass();
        if( type != null && type instanceof ParameterizedType ) {
            viewObjectClass = ( Class<V> )( ( ParameterizedType )type )
                    .getActualTypeArguments()[0];
        }else {
            throw new IllegalArgumentException( 
                    "Type argument <V> is empty!!" );
        }
    }
      
}
